{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "8eas33fwWYSi"
   },
   "source": [
    "# AIWIN-互联网舆情企业风险事件的识别和预警\n",
    "\n",
    "赛题链接：http://ailab.aiwin.org.cn/competitions/48\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "xicZSw7CZo7U"
   },
   "source": [
    "## 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T12:58:36.626310Z",
     "iopub.status.busy": "2021-05-12T12:58:36.625714Z",
     "iopub.status.idle": "2021-05-12T12:58:37.369726Z",
     "shell.execute_reply": "2021-05-12T12:58:37.369140Z",
     "shell.execute_reply.started": "2021-05-12T12:58:36.626259Z"
    },
    "id": "OUMZfdK2ShBP",
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Populating the interactive namespace from numpy and matplotlib\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd # 读取文件pandas 结构化数据\n",
    "import jieba # 中文分词\n",
    "import numpy as np # 矩阵/线性运算\n",
    "\n",
    "# 绘图函数\n",
    "%pylab inline\n",
    "import seaborn as sns\n",
    "\n",
    "# 不要显示警告\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n",
    "warnings.simplefilter(\"ignore\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T12:58:37.370715Z",
     "iopub.status.busy": "2021-05-12T12:58:37.370536Z",
     "iopub.status.idle": "2021-05-12T12:58:37.697498Z",
     "shell.execute_reply": "2021-05-12T12:58:37.696450Z",
     "shell.execute_reply.started": "2021-05-12T12:58:37.370698Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "company_name = pd.read_excel('2_公司实体汇总_20210414_A1.xlsx', names=['name'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T12:58:37.698506Z",
     "iopub.status.busy": "2021-05-12T12:58:37.698329Z",
     "iopub.status.idle": "2021-05-12T12:58:37.706593Z",
     "shell.execute_reply": "2021-05-12T12:58:37.706125Z",
     "shell.execute_reply.started": "2021-05-12T12:58:37.698489Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>武汉卡伊娜化妆品有限公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>北京泰禾锦绣置业有限公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>长城新盛信托有限责任公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>招商银行股份有限公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>中国长城资产管理股份有限公司</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             name\n",
       "0    武汉卡伊娜化妆品有限公司\n",
       "1    北京泰禾锦绣置业有限公司\n",
       "2    长城新盛信托有限责任公司\n",
       "3      招商银行股份有限公司\n",
       "4  中国长城资产管理股份有限公司"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_name.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T12:59:43.107856Z",
     "iopub.status.busy": "2021-05-12T12:59:43.107197Z",
     "iopub.status.idle": "2021-05-12T12:59:44.789441Z",
     "shell.execute_reply": "2021-05-12T12:59:44.788560Z",
     "shell.execute_reply.started": "2021-05-12T12:59:43.107806Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "train_data = pd.read_excel('3_训练集汇总_20210414_A1.xlsx')\n",
    "train_data.drop(0, inplace=True, axis=0)\n",
    "# train_data = train_data[['NEWS_TITLE', 'COMPANY_NM', 'LABEL']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:00:20.506622Z",
     "iopub.status.busy": "2021-05-12T13:00:20.506057Z",
     "iopub.status.idle": "2021-05-12T13:00:29.914124Z",
     "shell.execute_reply": "2021-05-12T13:00:29.913058Z",
     "shell.execute_reply.started": "2021-05-12T13:00:20.506573Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "test_data = pd.read_excel('测试集-1.xlsx')\n",
    "test_data = test_data.iloc[:22288]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:24:44.040586Z",
     "iopub.status.busy": "2021-05-12T13:24:44.040010Z",
     "iopub.status.idle": "2021-05-12T13:24:44.058714Z",
     "shell.execute_reply": "2021-05-12T13:24:44.058089Z",
     "shell.execute_reply.started": "2021-05-12T13:24:44.040538Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>NEWS_BASICINFO_SID</th>\n",
       "      <th>NEWS_TITLE</th>\n",
       "      <th>ABSTRACT</th>\n",
       "      <th>CONTENT</th>\n",
       "      <th>AUTHOR</th>\n",
       "      <th>SRC_URL</th>\n",
       "      <th>SOURCE_TYPE</th>\n",
       "      <th>PUBLISH_SITE</th>\n",
       "      <th>FIRST_WEB</th>\n",
       "      <th>CHANNEL</th>\n",
       "      <th>NOTICE_DT</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>267188181.0</td>\n",
       "      <td>海能达在美“中招”摩托罗拉，陪审团裁决赔53亿元</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;article class=\"article\" id=\"mp-editor\"&gt;\\n    ...</td>\n",
       "      <td>知产力</td>\n",
       "      <td>http://www.sohu.com/a/373747099_221481</td>\n",
       "      <td>01</td>\n",
       "      <td>知产力</td>\n",
       "      <td>搜狐新闻</td>\n",
       "      <td>搜狐新闻</td>\n",
       "      <td>2020-02-17 18:16:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>267188183.0</td>\n",
       "      <td>博天环境收监管函：募资补充流动资金到期无法归还 涉3.1亿元</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;div id=\"content\" class=\"J-article-content art...</td>\n",
       "      <td>点点新闻</td>\n",
       "      <td>http://mini.eastday.com/a/200108164603613.html</td>\n",
       "      <td>09</td>\n",
       "      <td>中国科技新闻</td>\n",
       "      <td>中国科技新闻</td>\n",
       "      <td>点点新闻</td>\n",
       "      <td>2020-01-08 16:46:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>267188188.0</td>\n",
       "      <td>房企生存艰难群像：卖项目求生 中小房企生存难</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;p&gt;广州，房价近四年连续上涨的一线城市，今年却出现了多家破产房企；还有多家中小房企或项目公...</td>\n",
       "      <td>乐居网</td>\n",
       "      <td>https://feng.ifeng.com/c/7uGQGsUm52Q</td>\n",
       "      <td>01</td>\n",
       "      <td>乐居网</td>\n",
       "      <td>大风号</td>\n",
       "      <td>大风号</td>\n",
       "      <td>2020-02-22 07:08:35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>267188190.0</td>\n",
       "      <td>康盛股份：实际控制人将变更为解直锟</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;p&gt;&lt;span&gt;17:16&lt;/span&gt;【康盛股份：实际控制人将变更为解直锟】康盛股份晚间...</td>\n",
       "      <td>第一财经</td>\n",
       "      <td>https://www.yicai.com/brief/100408733.html</td>\n",
       "      <td>01</td>\n",
       "      <td>第一财经</td>\n",
       "      <td>第一财经</td>\n",
       "      <td>正在</td>\n",
       "      <td>2019-11-19 17:16:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>267188194.0</td>\n",
       "      <td>衣服丑，价格高！“中国版Zara”关店2400家，坑惨投资者！</td>\n",
       "      <td>NaN</td>\n",
       "      <td>&lt;article class=\"article\" id=\"mp-editor\"&gt;\\n    ...</td>\n",
       "      <td>财经锐眼</td>\n",
       "      <td>http://www.sohu.com/a/332422701_545836</td>\n",
       "      <td>01</td>\n",
       "      <td>财经锐眼</td>\n",
       "      <td>搜狐新闻</td>\n",
       "      <td>搜狐新闻</td>\n",
       "      <td>2019-08-08 19:52:00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22283</th>\n",
       "      <td>310002394.0</td>\n",
       "      <td>云商集团与您互惠互利共创财富</td>\n",
       "      <td>/</td>\n",
       "      <td>云商集团与您互惠互利共创财富</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22284</th>\n",
       "      <td>310002395.0</td>\n",
       "      <td>山东能源集团：“众创”热情高 攒足发展后劲</td>\n",
       "      <td>/</td>\n",
       "      <td>山东能源集团：“众创”热情高 攒足发展后劲</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22285</th>\n",
       "      <td>310002396.0</td>\n",
       "      <td>2016中国华能集团公司博士后科研工作站博士后招收公告</td>\n",
       "      <td>/</td>\n",
       "      <td>2016中国华能集团公司博士后科研工作站博士后招收公告</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22286</th>\n",
       "      <td>310002397.0</td>\n",
       "      <td>3月24日文通集团钾盐价格动态</td>\n",
       "      <td>/</td>\n",
       "      <td>3月24日文通集团钾盐价格动态</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22287</th>\n",
       "      <td>310002398.0</td>\n",
       "      <td>【广西】2016春季中国银行消费金融有限公司招聘88人公告</td>\n",
       "      <td>/</td>\n",
       "      <td>【广西】2016春季中国银行消费金融有限公司招聘88人公告</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "      <td>/</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>22288 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       NEWS_BASICINFO_SID                       NEWS_TITLE ABSTRACT  \\\n",
       "0             267188181.0         海能达在美“中招”摩托罗拉，陪审团裁决赔53亿元      NaN   \n",
       "1             267188183.0   博天环境收监管函：募资补充流动资金到期无法归还 涉3.1亿元      NaN   \n",
       "2             267188188.0           房企生存艰难群像：卖项目求生 中小房企生存难      NaN   \n",
       "3             267188190.0                康盛股份：实际控制人将变更为解直锟      NaN   \n",
       "4             267188194.0  衣服丑，价格高！“中国版Zara”关店2400家，坑惨投资者！      NaN   \n",
       "...                   ...                              ...      ...   \n",
       "22283         310002394.0                   云商集团与您互惠互利共创财富        /   \n",
       "22284         310002395.0            山东能源集团：“众创”热情高 攒足发展后劲        /   \n",
       "22285         310002396.0      2016中国华能集团公司博士后科研工作站博士后招收公告        /   \n",
       "22286         310002397.0                  3月24日文通集团钾盐价格动态        /   \n",
       "22287         310002398.0    【广西】2016春季中国银行消费金融有限公司招聘88人公告        /   \n",
       "\n",
       "                                                 CONTENT AUTHOR  \\\n",
       "0      <article class=\"article\" id=\"mp-editor\">\\n    ...    知产力   \n",
       "1      <div id=\"content\" class=\"J-article-content art...   点点新闻   \n",
       "2      <p>广州，房价近四年连续上涨的一线城市，今年却出现了多家破产房企；还有多家中小房企或项目公...    乐居网   \n",
       "3      <p><span>17:16</span>【康盛股份：实际控制人将变更为解直锟】康盛股份晚间...   第一财经   \n",
       "4      <article class=\"article\" id=\"mp-editor\">\\n    ...   财经锐眼   \n",
       "...                                                  ...    ...   \n",
       "22283                                     云商集团与您互惠互利共创财富      /   \n",
       "22284                              山东能源集团：“众创”热情高 攒足发展后劲      /   \n",
       "22285                        2016中国华能集团公司博士后科研工作站博士后招收公告      /   \n",
       "22286                                    3月24日文通集团钾盐价格动态      /   \n",
       "22287                      【广西】2016春季中国银行消费金融有限公司招聘88人公告      /   \n",
       "\n",
       "                                              SRC_URL SOURCE_TYPE  \\\n",
       "0              http://www.sohu.com/a/373747099_221481          01   \n",
       "1      http://mini.eastday.com/a/200108164603613.html          09   \n",
       "2                https://feng.ifeng.com/c/7uGQGsUm52Q          01   \n",
       "3          https://www.yicai.com/brief/100408733.html          01   \n",
       "4              http://www.sohu.com/a/332422701_545836          01   \n",
       "...                                               ...         ...   \n",
       "22283                                               /           /   \n",
       "22284                                               /           /   \n",
       "22285                                               /           /   \n",
       "22286                                               /           /   \n",
       "22287                                               /           /   \n",
       "\n",
       "      PUBLISH_SITE FIRST_WEB CHANNEL            NOTICE_DT  \n",
       "0              知产力      搜狐新闻    搜狐新闻  2020-02-17 18:16:00  \n",
       "1           中国科技新闻    中国科技新闻    点点新闻  2020-01-08 16:46:00  \n",
       "2              乐居网       大风号     大风号  2020-02-22 07:08:35  \n",
       "3             第一财经      第一财经      正在  2019-11-19 17:16:00  \n",
       "4             财经锐眼      搜狐新闻    搜狐新闻  2019-08-08 19:52:00  \n",
       "...            ...       ...     ...                  ...  \n",
       "22283            /         /       /                    /  \n",
       "22284            /         /       /                    /  \n",
       "22285            /         /       /                    /  \n",
       "22286            /         /       /                    /  \n",
       "22287            /         /       /                    /  \n",
       "\n",
       "[22288 rows x 11 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:00:59.658592Z",
     "iopub.status.busy": "2021-05-12T13:00:59.658015Z",
     "iopub.status.idle": "2021-05-12T13:00:59.755208Z",
     "shell.execute_reply": "2021-05-12T13:00:59.754677Z",
     "shell.execute_reply.started": "2021-05-12T13:00:59.658543Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def replace_postfix(s):\n",
    "    for x in '有限责任公司 股份有限公司 控股股份公司 总公司 有限公司 投资合伙企业 子公司 公司 集团'.split(' '):\n",
    "        if s[-len(x):] == x:    \n",
    "            return s[:-len(x)], x\n",
    "        \n",
    "    return s, None\n",
    "\n",
    "company_name['name2'] = company_name['name'].apply(replace_postfix)\n",
    "company_name['name_short'] = company_name['name2'].apply(lambda x: x[0])\n",
    "company_name['name_postfix'] = company_name['name2'].apply(lambda x: x[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:01:00.595046Z",
     "iopub.status.busy": "2021-05-12T13:01:00.594493Z",
     "iopub.status.idle": "2021-05-12T13:01:00.606847Z",
     "shell.execute_reply": "2021-05-12T13:01:00.606249Z",
     "shell.execute_reply.started": "2021-05-12T13:01:00.594998Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>name2</th>\n",
       "      <th>name_short</th>\n",
       "      <th>name_postfix</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>武汉卡伊娜化妆品有限公司</td>\n",
       "      <td>(武汉卡伊娜化妆品, 有限公司)</td>\n",
       "      <td>武汉卡伊娜化妆品</td>\n",
       "      <td>有限公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>北京泰禾锦绣置业有限公司</td>\n",
       "      <td>(北京泰禾锦绣置业, 有限公司)</td>\n",
       "      <td>北京泰禾锦绣置业</td>\n",
       "      <td>有限公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>长城新盛信托有限责任公司</td>\n",
       "      <td>(长城新盛信托, 有限责任公司)</td>\n",
       "      <td>长城新盛信托</td>\n",
       "      <td>有限责任公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>招商银行股份有限公司</td>\n",
       "      <td>(招商银行, 股份有限公司)</td>\n",
       "      <td>招商银行</td>\n",
       "      <td>股份有限公司</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>中国长城资产管理股份有限公司</td>\n",
       "      <td>(中国长城资产管理, 股份有限公司)</td>\n",
       "      <td>中国长城资产管理</td>\n",
       "      <td>股份有限公司</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             name               name2 name_short name_postfix\n",
       "0    武汉卡伊娜化妆品有限公司    (武汉卡伊娜化妆品, 有限公司)   武汉卡伊娜化妆品         有限公司\n",
       "1    北京泰禾锦绣置业有限公司    (北京泰禾锦绣置业, 有限公司)   北京泰禾锦绣置业         有限公司\n",
       "2    长城新盛信托有限责任公司    (长城新盛信托, 有限责任公司)     长城新盛信托       有限责任公司\n",
       "3      招商银行股份有限公司      (招商银行, 股份有限公司)       招商银行       股份有限公司\n",
       "4  中国长城资产管理股份有限公司  (中国长城资产管理, 股份有限公司)   中国长城资产管理       股份有限公司"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_name.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:01:01.455918Z",
     "iopub.status.busy": "2021-05-12T13:01:01.455385Z",
     "iopub.status.idle": "2021-05-12T13:01:01.473469Z",
     "shell.execute_reply": "2021-05-12T13:01:01.472861Z",
     "shell.execute_reply.started": "2021-05-12T13:01:01.455870Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>name2</th>\n",
       "      <th>name_short</th>\n",
       "      <th>name_postfix</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>瑞华会计师事务所（特殊普通合伙）</td>\n",
       "      <td>(瑞华会计师事务所（特殊普通合伙）, None)</td>\n",
       "      <td>瑞华会计师事务所（特殊普通合伙）</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>中国人民财产保险股份有限公司涟水支公司高沟营销服务部</td>\n",
       "      <td>(中国人民财产保险股份有限公司涟水支公司高沟营销服务部, None)</td>\n",
       "      <td>中国人民财产保险股份有限公司涟水支公司高沟营销服务部</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>中国工商银行股份有限公司克拉玛依石油分行</td>\n",
       "      <td>(中国工商银行股份有限公司克拉玛依石油分行, None)</td>\n",
       "      <td>中国工商银行股份有限公司克拉玛依石油分行</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>中国工商银行股份有限公司襄阳分行</td>\n",
       "      <td>(中国工商银行股份有限公司襄阳分行, None)</td>\n",
       "      <td>中国工商银行股份有限公司襄阳分行</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>216</th>\n",
       "      <td>内黄县农村信用合作联社</td>\n",
       "      <td>(内黄县农村信用合作联社, None)</td>\n",
       "      <td>内黄县农村信用合作联社</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15923</th>\n",
       "      <td>东莞银行股份有限公司合肥分行</td>\n",
       "      <td>(东莞银行股份有限公司合肥分行, None)</td>\n",
       "      <td>东莞银行股份有限公司合肥分行</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15924</th>\n",
       "      <td>东吴期货有限公司泉州营业部</td>\n",
       "      <td>(东吴期货有限公司泉州营业部, None)</td>\n",
       "      <td>东吴期货有限公司泉州营业部</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15926</th>\n",
       "      <td>大信会计师事务所（特殊普通合伙）</td>\n",
       "      <td>(大信会计师事务所（特殊普通合伙）, None)</td>\n",
       "      <td>大信会计师事务所（特殊普通合伙）</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15934</th>\n",
       "      <td>衡水银行股份有限公司站前支行</td>\n",
       "      <td>(衡水银行股份有限公司站前支行, None)</td>\n",
       "      <td>衡水银行股份有限公司站前支行</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15935</th>\n",
       "      <td>南京金维格服装产业投资合伙企业（有限合伙）</td>\n",
       "      <td>(南京金维格服装产业投资合伙企业（有限合伙）, None)</td>\n",
       "      <td>南京金维格服装产业投资合伙企业（有限合伙）</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>464 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                             name                               name2  \\\n",
       "87               瑞华会计师事务所（特殊普通合伙）            (瑞华会计师事务所（特殊普通合伙）, None)   \n",
       "118    中国人民财产保险股份有限公司涟水支公司高沟营销服务部  (中国人民财产保险股份有限公司涟水支公司高沟营销服务部, None)   \n",
       "138          中国工商银行股份有限公司克拉玛依石油分行        (中国工商银行股份有限公司克拉玛依石油分行, None)   \n",
       "139              中国工商银行股份有限公司襄阳分行            (中国工商银行股份有限公司襄阳分行, None)   \n",
       "216                   内黄县农村信用合作联社                 (内黄县农村信用合作联社, None)   \n",
       "...                           ...                                 ...   \n",
       "15923              东莞银行股份有限公司合肥分行              (东莞银行股份有限公司合肥分行, None)   \n",
       "15924               东吴期货有限公司泉州营业部               (东吴期货有限公司泉州营业部, None)   \n",
       "15926            大信会计师事务所（特殊普通合伙）            (大信会计师事务所（特殊普通合伙）, None)   \n",
       "15934              衡水银行股份有限公司站前支行              (衡水银行股份有限公司站前支行, None)   \n",
       "15935       南京金维格服装产业投资合伙企业（有限合伙）       (南京金维格服装产业投资合伙企业（有限合伙）, None)   \n",
       "\n",
       "                       name_short name_postfix  \n",
       "87               瑞华会计师事务所（特殊普通合伙）         None  \n",
       "118    中国人民财产保险股份有限公司涟水支公司高沟营销服务部         None  \n",
       "138          中国工商银行股份有限公司克拉玛依石油分行         None  \n",
       "139              中国工商银行股份有限公司襄阳分行         None  \n",
       "216                   内黄县农村信用合作联社         None  \n",
       "...                           ...          ...  \n",
       "15923              东莞银行股份有限公司合肥分行         None  \n",
       "15924               东吴期货有限公司泉州营业部         None  \n",
       "15926            大信会计师事务所（特殊普通合伙）         None  \n",
       "15934              衡水银行股份有限公司站前支行         None  \n",
       "15935       南京金维格服装产业投资合伙企业（有限合伙）         None  \n",
       "\n",
       "[464 rows x 4 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_name[company_name['name_postfix'].isnull()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:01:03.070733Z",
     "iopub.status.busy": "2021-05-12T13:01:03.070162Z",
     "iopub.status.idle": "2021-05-12T13:01:03.079371Z",
     "shell.execute_reply": "2021-05-12T13:01:03.078680Z",
     "shell.execute_reply.started": "2021-05-12T13:01:03.070685Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "train_data = train_data[['NEWS_TITLE', 'CONTENT','COMPANY_NM', 'LABEL']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 构建模型：风险标签识别"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:01:04.014847Z",
     "iopub.status.busy": "2021-05-12T13:01:04.014307Z",
     "iopub.status.idle": "2021-05-12T13:01:04.103553Z",
     "shell.execute_reply": "2021-05-12T13:01:04.102507Z",
     "shell.execute_reply.started": "2021-05-12T13:01:04.014800Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import LabelEncoder\n",
    "\n",
    "# 数据集打散\n",
    "# 标签不是均匀分布的\n",
    "train_data = train_data.sample(frac = 1.0)\n",
    "\n",
    "# 训练集做一个编码\n",
    "lbl = LabelEncoder().fit(train_data['LABEL'])\n",
    "train_data['LABEL'] = lbl.transform(train_data['LABEL'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:01:17.630692Z",
     "iopub.status.busy": "2021-05-12T13:01:17.630127Z",
     "iopub.status.idle": "2021-05-12T13:01:20.265244Z",
     "shell.execute_reply": "2021-05-12T13:01:20.264084Z",
     "shell.execute_reply.started": "2021-05-12T13:01:17.630645Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import jieba\n",
    "\n",
    "def strcut(s):\n",
    "    seg_list = jieba.cut(s)\n",
    "    return ' '.join(list(seg_list))\n",
    "\n",
    "# 新闻标题\n",
    "train_title = train_data['NEWS_TITLE'].apply(strcut)\n",
    "test_title = test_data['NEWS_TITLE'].apply(strcut)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### TFIDF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:09:52.242454Z",
     "iopub.status.busy": "2021-05-12T13:09:52.241857Z",
     "iopub.status.idle": "2021-05-12T13:09:52.365710Z",
     "shell.execute_reply": "2021-05-12T13:09:52.365099Z",
     "shell.execute_reply.started": "2021-05-12T13:09:52.242405Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "\n",
    "# TFIDF / FASTTEXT / WORD2VEC / BERT\n",
    "# TFIDF -> TF * IDF\n",
    "# 词袋编码 countervector\n",
    "# IDF 单词在所有文档出现次数的频率的倒数\n",
    "\n",
    "# https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html\n",
    "tfidf = TfidfVectorizer(ngram_range=(1,1))\n",
    "train_title_ttidf = tfidf.fit_transform(train_title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:09:52.830254Z",
     "iopub.status.busy": "2021-05-12T13:09:52.829661Z",
     "iopub.status.idle": "2021-05-12T13:09:52.852541Z",
     "shell.execute_reply": "2021-05-12T13:09:52.851887Z",
     "shell.execute_reply.started": "2021-05-12T13:09:52.830204Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import cross_val_score\n",
    "from sklearn.linear_model import RidgeClassifier\n",
    "\n",
    "# 定义分类器\n",
    "clf = RidgeClassifier()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:10:28.655721Z",
     "iopub.status.busy": "2021-05-12T13:10:28.655153Z",
     "iopub.status.idle": "2021-05-12T13:10:28.670702Z",
     "shell.execute_reply": "2021-05-12T13:10:28.669520Z",
     "shell.execute_reply.started": "2021-05-12T13:10:28.655674Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 数据集进行划分（holdout）：按照比例进行划分\n",
    "# 留出法（按照比例）、kfold、采样\n",
    "# 训练集、 验证集\n",
    "\n",
    "# train_data['NEWS_TITLE'] ：原始文本（分词前）\n",
    "# train_title_ttidf： 分词后并提取TFIDF\n",
    "# train_data['LABEL']： 分类标签\n",
    "# stratify：划分数据集的依据（按照标签进行划分）\n",
    "# test_size：测试集占比\n",
    "tr_x, val_x, tr_tfidf, val_tfidf, tr_y, val_y = train_test_split(\n",
    "    train_data['NEWS_TITLE'], train_title_ttidf, train_data['LABEL'],\n",
    "    stratify = train_data['LABEL'],\n",
    "    test_size=0.1\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:10:29.214578Z",
     "iopub.status.busy": "2021-05-12T13:10:29.214028Z",
     "iopub.status.idle": "2021-05-12T13:10:29.659105Z",
     "shell.execute_reply": "2021-05-12T13:10:29.658649Z",
     "shell.execute_reply.started": "2021-05-12T13:10:29.214529Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8708297690333618"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf.fit(tr_tfidf, tr_y)\n",
    "clf.score(val_tfidf, val_y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 构建模型：公司主体识别"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 规则匹配"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:10:09.412776Z",
     "iopub.status.busy": "2021-05-12T13:10:09.412213Z",
     "iopub.status.idle": "2021-05-12T13:10:10.877026Z",
     "shell.execute_reply": "2021-05-12T13:10:10.876569Z",
     "shell.execute_reply.started": "2021-05-12T13:10:09.412729Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "标题： 银保监会对“原油宝”事件作出处罚，中国银行：认罚、反思！\n",
      "主体标签： 中国银行股份有限公司\n",
      "主体识别结果： 中国银行股份有限公司\n",
      "\n",
      "标题： 德州银行烟台2宗违法遭罚85万 3分支机构行长遭警告\n",
      "主体标签： 德州银行股份有限公司烟台分行\n",
      "主体识别结果： 德州银行股份有限公司\n",
      "\n",
      "标题： 2020年，负债累累的轮胎企业！\n",
      "主体标签： 山东富宇蓝石轮胎有限公司\n",
      "主体识别结果： \n",
      "\n",
      "标题： 资金管控不严被挪用，浦发银行徐州分行、平安银行南京分行被罚\n",
      "主体标签： 上海浦东发展银行股份有限公司徐州分行\n",
      "主体识别结果： 平安银行股份有限公司\n",
      "\n",
      "标题： 银行代销乱象频出！没销售资格却在卖产品、借贷搭售多套路，这7家银行被“点名”\n",
      "主体标签： 江苏银行股份有限公司\n",
      "主体识别结果： \n",
      "\n",
      "标题： 财务不真实、虚构中介业务套取手续费  人保财险莆田市多家分支机构合计被罚109.3万元\n",
      "主体标签： 中国人民财产保险股份有限公司莆田市城厢支公司城南营销服务部\n",
      "主体识别结果： \n",
      "\n",
      "标题： 四川蓝光发展股份有限公司公告（系列）\n",
      "主体标签： /\n",
      "主体识别结果： 四川蓝光发展股份有限公司\n",
      "\n",
      "标题： 被证监会立案调查，德威新材离氢能界“第二个宁德时代”渐行渐远\n",
      "主体标签： 江苏德威新材料股份有限公司\n",
      "主体识别结果： \n",
      "\n",
      "标题： 2019年国有企业丽水市农业投资发展有限公司公开招聘工作人员公告\n",
      "主体标签： /\n",
      "主体识别结果： \n",
      "\n",
      "标题： 淮北矿业集团财务有限公司朱仙庄煤矿突水事故已致6人遇难\n",
      "主体标签： 淮北矿业集团财务有限公司\n",
      "主体识别结果： 淮北矿业集团财务有限公司\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for row in train_data.iloc[:10].iterrows():\n",
    "    # company_name 已知的企业名字\n",
    "    match1 = company_name[company_name['name'].apply(lambda x: x in row[1].NEWS_TITLE)]\n",
    "    if match1.shape[0] > 0:\n",
    "        match1.loc[:, 'name_len'] = match1['name'].apply(len)\n",
    "        match1 = match1.sort_values(by='name_len')\n",
    "        match1 = match1.iloc[-1]['name']\n",
    "    else:\n",
    "        match1 = ''\n",
    "    \n",
    "    match2 = company_name[company_name['name_short'].apply(lambda x: x in row[1].NEWS_TITLE)]\n",
    "    if match2.shape[0] > 0 and match1 == '':\n",
    "        match2.loc[:, 'name_len'] = match2['name_short'].apply(len)\n",
    "        match2 = match2.sort_values(by='name_len')\n",
    "        match2 = match2.iloc[-1]['name']\n",
    "    else:\n",
    "        match2 = ''\n",
    "    \n",
    "    print('标题：', row[1].NEWS_TITLE)\n",
    "    print('主体标签：', row[1]['COMPANY_NM'])\n",
    "    print('主体识别结果：', match1 + match2)\n",
    "    print('')\n",
    "    \n",
    "    # break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:25:42.237203Z",
     "iopub.status.busy": "2021-05-12T13:25:42.236645Z",
     "iopub.status.idle": "2021-05-12T13:25:42.412649Z",
     "shell.execute_reply": "2021-05-12T13:25:42.412117Z",
     "shell.execute_reply.started": "2021-05-12T13:25:42.237155Z"
    }
   },
   "outputs": [],
   "source": [
    "test_data['LABEL'] = lbl.inverse_transform(\n",
    "    clf.predict(tfidf.transform(test_title))\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:29:02.364411Z",
     "iopub.status.busy": "2021-05-12T13:29:02.363800Z",
     "iopub.status.idle": "2021-05-12T13:29:02.375127Z",
     "shell.execute_reply": "2021-05-12T13:29:02.374469Z",
     "shell.execute_reply.started": "2021-05-12T13:29:02.364354Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def search_result(row):\n",
    "    print(row)\n",
    "    # company_name 已知的企业名字\n",
    "    match1 = company_name[company_name['name'].apply(lambda x: x in row[1].NEWS_TITLE)]\n",
    "    if match1.shape[0] > 0:\n",
    "        match1.loc[:, 'name_len'] = match1['name'].apply(len)\n",
    "        match1 = match1.sort_values(by='name_len')\n",
    "        match1 = match1.iloc[-1]['name']\n",
    "    else:\n",
    "        match1 = ''\n",
    "    \n",
    "    match2 = company_name[company_name['name_short'].apply(lambda x: x in row[1].NEWS_TITLE)]\n",
    "    if match2.shape[0] > 0 and match1 == '':\n",
    "        match2.loc[:, 'name_len'] = match2['name_short'].apply(len)\n",
    "        match2 = match2.sort_values(by='name_len')\n",
    "        match2 = match2.iloc[-1]['name']\n",
    "    else:\n",
    "        match2 = ''\n",
    "    \n",
    "    if (match1 + match2) == '':\n",
    "        return str(int(row[1].NEWS_BASICINFO_SID)) + ',/,' + str(row[1].LABEL)\n",
    "    else:\n",
    "        return str(int(row[1].NEWS_BASICINFO_SID)) + ','+ match1+match2 + ','+ str(row[1].LABEL)\n",
    "    # break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:29:03.460818Z",
     "iopub.status.busy": "2021-05-12T13:29:03.460275Z",
     "iopub.status.idle": "2021-05-12T13:29:03.465838Z",
     "shell.execute_reply": "2021-05-12T13:29:03.464679Z",
     "shell.execute_reply.started": "2021-05-12T13:29:03.460771Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from joblib import Parallel, delayed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:34:51.676421Z",
     "iopub.status.busy": "2021-05-12T13:34:51.675863Z",
     "iopub.status.idle": "2021-05-12T13:37:29.820524Z",
     "shell.execute_reply": "2021-05-12T13:37:29.819684Z",
     "shell.execute_reply.started": "2021-05-12T13:34:51.676374Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "test_result = Parallel(n_jobs=5)(delayed(search_result)(row) \n",
    "                   for row in test_data.iloc[:5000].iterrows())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:33:40.396375Z",
     "iopub.status.busy": "2021-05-12T13:33:40.395770Z",
     "iopub.status.idle": "2021-05-12T13:33:40.401442Z",
     "shell.execute_reply": "2021-05-12T13:33:40.400781Z",
     "shell.execute_reply.started": "2021-05-12T13:33:40.396315Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import codecs\n",
    "with codecs.open('result.csv', 'w', encoding='utf-8-sig') as up:\n",
    "    for x in test_result:\n",
    "        up.write(x+'\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:33:41.626575Z",
     "iopub.status.busy": "2021-05-12T13:33:41.626039Z",
     "iopub.status.idle": "2021-05-12T13:33:41.786522Z",
     "shell.execute_reply": "2021-05-12T13:33:41.785447Z",
     "shell.execute_reply.started": "2021-05-12T13:33:41.626527Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "updating: result.csv (deflated 83%)\n"
     ]
    }
   ],
   "source": [
    "!zip  T1_finlay.zip result.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-12T13:34:41.468623Z",
     "iopub.status.busy": "2021-05-12T13:34:41.468012Z",
     "iopub.status.idle": "2021-05-12T13:34:41.474440Z",
     "shell.execute_reply": "2021-05-12T13:34:41.473652Z",
     "shell.execute_reply.started": "2021-05-12T13:34:41.468565Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(22288, 12)"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "AIWIN-互联网舆情企业风险事件的识别和预警.ipynb",
   "provenance": [],
   "toc_visible": true
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  },
  "toc-autonumbering": false,
  "toc-showmarkdowntxt": false,
  "toc-showtags": false
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
